<?php

namespace App\Models;

use App\Models\Traits\Timestamp;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Foundation\Auth\User;
use Illuminate\Notifications\Notifiable;
use Tymon\JWTAuth\Contracts\JWTSubject;

class AppUser extends User implements JWTSubject
{
    use HasFactory, Notifiable,Timestamp;

    protected $fillable = [
        'id','mobile','nickname','balance','icon','password','invite',
    ];

    protected $hidden = [
        'password'
    ];

    public function bank()
    {
        return $this->belongsTo(AppUserBank::class,'id','user_id');
    }

    public function invite_user()
    {
        return $this->belongsTo(AppUser::class,'invite','mobile');
    }

    public function getJWTIdentifier()
    {
        return $this->getKey();
    }

    public function getJWTCustomClaims()
    {
        return ['role'=>'app'];
    }
}
